<?php

namespace Home\Model;
use Think\Model;

/**
* @desc 
*/
class WithdrawalsHistoryModel extends Model {
	protected $tableName = 'withdrawals_history';
	//新增提现记录
	public function writeWithdrawals(){

	}

	//获取某用户，某提现详情
	public function getInfo($uid=null,$id=null){
		if(empty($uid) || empty($id)) return null;

		$where['uid'] = $uid;
		$where['id'] = $id;
		return $this->where($where)->find();
		
	}
	
	//获取某用户提现记录列表
	public function getList($uid=null,$page=1,$pagesize=20){
		if(empty($uid)) return null;
		if($page < 1 || !is_numeric($page)) $page = 1;
		if($pagesize < 1 || !is_numeric($pagesize)) $pagesize = 20;

		$where['uid'] = $uid;
		$offset = ($page-1)*$pagesize;
		$count = $this->where($where)->count();

		$list = $this->where($where)->limit($offset.",".$pagesize)->order('id desc')->select();

		$return['total_page'] = ceil($count/$pagesize);
		$return['current_page'] = $page;
		$return['data'] = $list;

		return $return;
	}

	//获取某用户正在提现的记录列表
	public function getIngList($uid=null){
		if(empty($uid)) return null;

		$where['uid'] = $uid;
		$where['review_status'] = 0;//提交审核中
		
		return $this->where($where)->select();

	}


	
}

?>